<?php  
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
class feed_controller extends CI_Controller
{
	function __construct()
	{
		parent::__construct();
		//$this->load->model('hello_model');
		//$this->load->model('apply_model');
		$this->load->model('user_model');
	}
	function index()
	{

			$data['title']="Hello World";
			$this->load->view('header',$data);
			$this->load->view('feed_view');
			$data['id']="feed";
			$this->load->view('footer',$data);

		
		//$data['rows'] = $this->hello_model->ChangeQureyResultToArray( $this->hello_model->getAll() );
		//$data['main_content'] = 'feedpage_view';
		//$this->load->view('includes/template', $data);
	}
	/*function to_apply()
	{
		$profile['helloid']= $this->input->get('info');
		$this->session->set_userdata($profile);
		$Qresult = $this->hello_model->ChangeQureyResultToArray( $this->hello_model->get_hello($profile) );
		$temp = $Qresult[0];
		
		
		$data['row'] = $temp;
		$data['main_content'] = 'hello_apply_view';
		$this->load->view('includes/template',$data);
	}
	function apply()
	{
		$helloid = $this->session->userdata('helloid');
		echo $helloid;
		if ($this->apply_model->link($helloid) )
			$this->load->view('apply_hello_success_view');
		else
			$this->load->view('apply_hello_fail_view');
	}
	function read_applicants()
	{
		$profile['helloid']= $this->input->get('info');
		$res = $this->apply_model->get_apply($profile);
		$data['is_empty'] = ($res->num_rows() == 0);

		$r = $this->apply_model->ChangeQureyResultToArray($res);
		if(!$data['is_empty'])
		{
			foreach($r as $element)
			{
			$profile2['userid'] = $element->guestid;
			$t = $this->user_model->ChangeQureyResultToArray( $this->user_model->get_user($profile2) );
			$temp[] = $t[0]; 				
			}
			$data['rows']=$temp;

		}
		$data['main_content'] = 'read_applicants_view';
		$data['helloid'] = $profile['helloid'];
		$this->load->view('includes/template',$data);
	}
	function to_confirm_guest()
	{
		$profile['userid']= $this->input->get('info');
		$data['helloid'] = $this->input->get('info2');
		 $temp = $this->user_model->ChangeQureyResultToArray( $this->user_model->get_user($profile) );
		 $data['r']  = $temp[0];
		$data['main_content'] = 'confirm_applicants_view';
		$this->load->view('includes/template',$data);
	}
	function confirm_guest()
	{
		//many things to do
		$profile['guestid'] = $this->input->get('info');
		$profile['helloid'] = $this->input->get('info2');
		$profile['isconfirmed'] = true;
		$this->hello_model->update($profile);
		//send notification to all applicants
	}*/

}
?>
